/-app
/-files ...
FileTree.ts
SyncStorageAccess.ts
/-imports
/-imports/codemirror
/-imports/jquery
/-storage
/-typings
functions.ts
index.html
try.js
x
 
28
        && text.charAt(parentPath.length) === '/') {
29
        fullPath = text;
30
        name = text.slice(parentPath.length + 1);
31
      }
32
      else {
33
        fullPath = parentPath + text;
34
        name = text.slice(1);
35
      }
36
    }
37
    else {
38
      fullPath = parentPath + '/' + text;
39
      name = text;
40
    }
41
​
42
    if (name.indexOf('/')) {
43
      // TODO: figure out something about invalid names with slashes
44
    }
45
​
46
    var ul = getChildUL(li);
47
    
48
    var children = getChildren(fullPath, ul);
49
    
50
    return {
51
      li: li,
52
      name: name,
53
      fullPath: fullPath,
54
      children: children
55
    };
56
    
57
  }
58
​
59
  function getLIText(li: HTMLLIElement): string { 
60
    
61
    for (var i = 0; i < li.childNodes.length; i++) {
62
      
63
      var node = li.childNodes.item(i);
64
      if ((<HTMLElement>node).tagName) continue;
65
      // TODO: check something for tag type
66
​
67
      return node.textContent;
68
    }
69
​
70
    return null;
71
  }
72
​
73
  function getChildUL(li: HTMLLIElement): HTMLUListElement { 
74
    for (var i = 0; i < li.children.length; i++) {
75
      var ul = li.children.item(i);
76
      if (ul.tagName === 'UL' ||
77
        (ul.tagName && ul.tagName.toLowerCase() == 'ul'))
78
        return <HTMLUListElement>ul;
79
    }
80
    return null;
81
  }
82
​
83
  function getChildren(parentPath: string, ul: HTMLUListElement): Entry[] {
84
    var result: Entry[] = [];
85
    for (var i = 0; i < ul.children.length; i++) {
86
      var li = <HTMLLIElement>ul.children.item(i);
87
      if (li.tagName == 'LI'
88
       || (li.tagName && li.tagName.toLowerCase() == 'li')) {
89
        var childEntry = loadEntry(parentPath, li);
90
        result.push(childEntry);
91
      }
92
    }
93
    return result;
94
  }
95
​
96
}
85:29